package com.taxi.driver.module.main.home;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.qianxx.adapter.SuperAdapter;
import com.qianxx.adapter.internal.SuperViewHolder;
import com.qianxx.utils.DateUtil;
import com.taxi.driver.R;
import com.taxi.driver.module.vo.OrderSummaryVO;

import java.util.ArrayList;

public class AppointmentAdapter extends SuperAdapter<OrderSummaryVO> {

    public AppointmentAdapter(Context context) {
        super(context, new ArrayList<>(), R.layout.item_appointment);
    }

    @Override
    public void onBind(SuperViewHolder holder, int viewType, int position, OrderSummaryVO item) {
        holder.setText(R.id.tv_start, item.getOriginAddress());
        holder.setText(R.id.tv_end, item.getDestAddress());
        holder.setText(R.id.tv_time, DateUtil.getAppointmentTime(item.deparTime));

        TextView tvType = holder.getView(R.id.tv_type);
        int resId = OrderSummaryVO.tripType(item.typeTripNew, item.typeTimeNew);
        if (resId == 0) {
            tvType.setVisibility(View.GONE);
        } else {
            tvType.setText(resId);
            tvType.setVisibility(View.VISIBLE);
        }
    }
}
